﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace FBGraph.Models
{
    /// <summary>A Facebook Page</summary>
    /// <remarks>
    /// <para>Example: https://graph.facebook.com/platform (Facebook Platform)</para>
    /// </remarks>
    [JsonConverter(typeof(PageConverter))]
    public partial class Page : IFBGraphResult
    {
        /// <summary>Initializes an instance of <see cref="Page" />.</summary>
        public Page()
        {
            this.Details = new Dictionary<String, String>();
        }

        /// <summary>The page's ID</summary>
        [JsonProperty("id")]
        public Int64 Id { get; set; }

        /// <summary>The page's name</summary>
        [JsonProperty("name")]
        public String Name { get; set; }

        /// <summary>The page's category</summary>
        [JsonProperty("category")]
        public String Category { get; set; }

        /// <summary>The number of users who like the page.</summary>
        [JsonProperty("fan_count")]
        public Int64 FanCount { get; set; }

        /// <summary>The URL for the page's profile picture.</summary>
        [JsonProperty("picture")]
        public String Picture { get; set; }

        /// <summary>The URL to the page.</summary>
        [JsonProperty("link")]
        public String Link { get; set; }

        /// <summary>Gets or sets a <see cref="Boolean" /> value representing whether the object has been populated.</summary>
        Boolean IFBGraphResult.IsReady { get; set; }
        /// <summary>Updates the current model with values from another like-typed model.</summary>
        /// <param name="other">The source model.</param>
        /// <remarks>This is used for asynchronous calls to update the reference that was returned when the original API method was called.</remarks>
        void IFBGraphResult.UpdateFrom(IFBGraphResult other)
        {
            var that = other as Page;
            if (that == null) return;
            else
            {
                this.Id = that.Id;
                this.Name = that.Name;
                this.Category = that.Category;
                ((IFBGraphResult)this).IsReady = true;
            }

        }

        /// <summary>A dictionary of category-specific properties for the page.</summary>
        public IDictionary<String, String> Details { get; private set; }
    }
}